package cn.tedu.ivos.geofence.controller;

import cn.tedu.ivos.base.response.JsonResult;
import cn.tedu.ivos.geofence.pojo.dto.GeofenceParam;
import cn.tedu.ivos.geofence.pojo.dto.GeofenceQuery;
import cn.tedu.ivos.geofence.pojo.vo.GeofenceVO;
import cn.tedu.ivos.geofence.service.GeofenceService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author 482944566@qq.com
 * @version 1.0
 * @date 2024-12-04
 */

@Slf4j
@RestController
@RequestMapping("/v1/geofence")
public class GeofenceController {

    @Autowired
    private GeofenceService geofenceService;

    @GetMapping("select")
    public JsonResult selectGeofence(GeofenceQuery geofenceQuery) {
        log.debug("查询电子围栏列表，selectGeofence={}", geofenceQuery);
        List<GeofenceVO> list = geofenceService.selectGeofence(geofenceQuery);
        return JsonResult.ok(list);
    }

    @PostMapping("save")
    public JsonResult saveGeofence(GeofenceParam geofenceParam) {
        log.debug("保存电子围栏数据：geofenceParam={}", geofenceParam);
        geofenceService.saveGeofence(geofenceParam);
        return JsonResult.ok();
    }

    @PostMapping("removeGeofence/{id}")
    public JsonResult RemoveGeofence(@PathVariable Long id){
        log.debug("删除围栏：id={}",id);
        geofenceService.removeGeofence(id);
        return JsonResult.ok();
    }
}
